from fastapi import APIRouter

from .crawler import (
    create_crawl_task,
    get_task_progress,
    get_task_result,
    import_articles,
    get_data_sources,
    get_source_latest_info,
    get_user_crawl_status,
    get_global_config_api,
    update_global_config_api,
)

router = APIRouter(prefix="/api/crawl_task", tags=["采集任务"])

# 统一在此绑定路由
router.add_api_route("", create_crawl_task, methods=["POST"])
router.add_api_route("/progress", get_task_progress, methods=["GET"])
router.add_api_route("/result", get_task_result, methods=["GET"])
router.add_api_route("/import", import_articles, methods=["POST"])
router.add_api_route("/data_sources", get_data_sources, methods=["GET"])
router.add_api_route("/source_latest_info", get_source_latest_info, methods=["GET"])
router.add_api_route("/status", get_user_crawl_status, methods=["GET"])
router.add_api_route("/global_config", get_global_config_api, methods=["GET"])
router.add_api_route("/global_config", update_global_config_api, methods=["POST"])